//计划订单下发
OB.Emes_ActionButton.Generate_Plan_Button = function(params, view) {
	var view = view.activeView.viewGrid;
	var records = view.getSelectedRecords();
	var length = records.getLength();

	if (length) {
		isc.confirm("确定申报计划？", function(ok) {
			if (ok) {
				// 选择纪录行
				var selectRecords = [];
				for ( var i = 0; i < length; i++) {
					selectRecords.push(records[i].id);
				}
				OB.RemoteCallManager.call(
						"com.mes.handler.GeneratePlanHandler", {
							ids : selectRecords.join("#####"),type:"GENERATE_PLAN"
						}, {}, function(request, data, response) {
							if (data.result) {
								view.refreshGrid();
								isc.showMessage(data.message);
							} else {
								isc.showMessage(data.message);
							}
						});
			}
		});
	} else {
		isc.showMessage("请选择纪录！");
	}
};


//设备保养计划审核
OB.Emes_ActionButton.Generate_Audit_Button = function(params, view) {
	var view = view.activeView.viewGrid;
	var records = view.getSelectedRecords();
	var length = records.getLength();

	if (length) {
		isc.confirm("确定审核通过？", function(ok) {
			if (ok) {
				// 选择纪录行
				var selectRecords = [];
				for ( var i = 0; i < length; i++) {
					selectRecords.push(records[i].id);
				}
				OB.RemoteCallManager.call(
						"com.mes.handler.GeneratePlanHandler", {
							ids : selectRecords.join("#####"),type:"AUDIT"
						}, {}, function(request, data, response) {
							if (data.result) {
								view.refreshGrid();
								isc.showMessage(data.message);
							} else {
								isc.showMessage(data.message);
							}
						});
			}
		});
	} else {
		isc.showMessage("请选择纪录！");
	}
};

//设备维修计划审核
OB.Emes_ActionButton.Equipment_Check_Button = function(params, view) {
	var view = view.activeView.viewGrid;
	var records = view.getSelectedRecords();
	var length = records.getLength();

	if (length) {
		isc.confirm("确定审核通过？", function(ok) {
			if (ok) {
				// 选择纪录行
				var selectRecords = [];
				for ( var i = 0; i < length; i++) {
					selectRecords.push(records[i].id);
				}
				OB.RemoteCallManager.call(
						"com.mes.handler.GeneratePlanHandler", {
							ids : selectRecords.join("#####"),type:"CHECK"
						}, {}, function(request, data, response) {
							if (data.result) {
								view.refreshGrid();
								isc.showMessage(data.message);
							} else {
								isc.showMessage(data.message);
							}
						});
			}
		});
	} else {
		isc.showMessage("请选择纪录！");
	}
};

//设备取消点检计划
OB.Emes_ActionButton.Cancel_Check_Button  = function(params, view) { 
		var views = view.activeView.viewGrid;
		var records = views.getSelectedRecords();
		var length = records.getLength();
		if (length) {
			isc.confirm("确定取消点检计划？", function(ok) {
				if (ok) {
					// 选择纪录行
					var selectRecords = [];
					for ( var i = 0; i < length; i++) {
						selectRecords.push(records[i].id);
					}
					OB.RemoteCallManager.call(
							"com.eam.handler.CheckCancelHandler", {
								ids : selectRecords.join("#####")
							}, {}, function(request, data, response) {
								if (data.flag) {
									views.refreshGrid();
									isc.showMessage(data.message);
								} else {
									isc.showMessage(data.message);
								}
							});
				}
			});
		} else {
			isc.showMessage("请选择纪录！");
		}
	}


//待维修设备清单开始维修按钮
OB.Emes_ActionButton.RepairHandler_Button  = function(params, view) { 
		var views = view.activeView.viewGrid;
		var records = views.getSelectedRecords();
		var length = records.getLength();
		if (length) {
			isc.confirm("确定开始？", function(ok) {
				if (ok) {
					// 选择纪录行
					var selectRecords = [];
					for ( var i = 0; i < length; i++) {
						selectRecords.push(records[i].id);
					}
					OB.RemoteCallManager.call(
							"com.mes.handler.RepairHandler", {
								ids : selectRecords.join("#####")
							}, {}, function(request, data, response) {
								if (data.flag) {
									views.refreshGrid();
									isc.showMessage(data.message);
								} else {
									isc.showMessage(data.message);
								}
							});
				}
			});
		} else {
			isc.showMessage("请选择纪录！");
		}
	}